import { z } from 'zod'
import { useLoaderData } from 'react-router-dom'
import { getConsts } from '@/consts/data'

const LoaderSchema = z.object({
  constResult: z.string(),
})

type LoaderData = z.infer<typeof LoaderSchema>

export async function loader() {
  const data: LoaderData = {
    constResult: getConsts(),
  }

  return data
}

export default function ConstsPage() {
  const { constResult } = LoaderSchema.parse(useLoaderData())

  return <p className="read-the-docs">consts:{constResult}</p>
}
